package h0806;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
  * @description 出错的或电路
  * @author 不知名帅哥
  * @date 2024/8/6 23:13
  * @version 1.0
*/
public class WrongOrCircuit {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n = sc.nextInt(); //二进制的位数
        sc.nextLine();
        String s1 = sc.nextLine();
        int a=Integer.parseInt(s1,2);
        String s2 = sc.nextLine();
        int b=Integer.parseInt(s2,2);

        int origin=a|b;
        System.out.println(getList(s1, b, origin));

    }

    //计算第一个二进制数每两个比特位交换的结果字符串，与第二个做或运算
    //判断是否跟原始计算结果origin相同。
    private static int getList(String s1,int b,int origin){
        List<Integer> list = new ArrayList<>();
        char[] chars = s1.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            for (int j = i+1; j <s1.length() ; j++) {
                swap(chars, i, j);
                String string = new String(chars);
                int parsed = Integer.parseInt(string, 2);
                int val=parsed|b;
                swap(chars, i, j); //交换回来
                if (origin==val){
                    continue;
                }
                list.add(val);
            }
        }
        return list.size();
    }

    private static void swap(char[] chars, int i, int j) {
        char temp= chars[i];
        chars[i]= chars[j];
        chars[j]=temp;
    }
}
